import request from '@/utils/request.js'

//注册接口函数
export const userRegisterService = (registerData) => {
    //为了避免使用json格式传参，借助UrlSearchParams完成传递
    const params = new URLSearchParams()
    for (let key in registerData) { params.append(key, registerData[key]); }
    return request.post('/api/user/register', params);
}

//登录接口函数
export const userLoginService = (loginData) => {
    const params = new URLSearchParams()
    for (let key in loginData) { params.append(key, loginData[key]); }
    return request.post('/api/user/login', params)
}

//查看用户详情
export const userInfoService = () => {
    return request.get('/api/user/userInfo');
}

//修改头像
export const userAvatarUpdateService = (avatarUrl) => {
    const params = new URLSearchParams();
    params.append('avatarUrl', avatarUrl)
    return request.patch('/api/user/uploadAvatar', params);
}
